<script setup>
	import { computed } from "vue"
	import { formatTimeDifference } from "@/utils/common.js"

	const props = defineProps({
		isMore: {
			type: Boolean,
			default: false
		},
		item: {
			type: Object,
			default: () => {
				return {
					name: "默认名称",
					picurl: "../../common/images/classify1.jpg",
					updateTime: Date.now() - 1000 * 60 * 60 * 5
				}
			}
		}
	})

	// 更新时间
	const updateTime = computed(() => {
		return formatTimeDifference(props.item.updateTime)
	})
</script>

<template>
	<view class="theme-content">
		<navigator class="theme-item" v-if="!isMore"
			:url="`/pages/classify-list/classify-list?id=${item._id}&name=${item.name}`">
			<image class="bg-img" :src="item.picurl"></image>
			<view class="mask">{{item.name}}</view>
			<view class="tab" v-if="updateTime">{{updateTime}}前更新</view>
		</navigator>
		<!-- 更多 -->
		<navigator class="theme-item more" v-else open-type="reLaunch" url="/pages/classify/classify">
			<image class="bg-img" src="../../common/images/more.jpg"></image>
			<view class="mask">
				<uni-icons type="more-filled" size="34" color="#fff"></uni-icons>
				<view class="text">更多</view>
			</view>
		</navigator>
	</view>
</template>

<style lang="scss" scoped>
	.theme-item {
		width: 100%;
		height: 340rpx;
		border-radius: 10rpx;
		overflow: hidden;
		position: relative;

		.bg-img {
			width: 100%;
			height: 100%;
		}

		.mask {
			position: absolute;
			left: 0;
			bottom: 0;
			width: 100%;
			height: 70rpx;
			color: #fff;
			background-color: rgba(0, 0, 0, 0.2);
			display: flex;
			align-items: center;
			justify-content: center;
			backdrop-filter: blur(20rpx);
		}

		.tab {
			position: absolute;
			left: 0;
			top: 0;
			background-color: rgba(250, 129, 90, 0.7);
			backdrop-filter: blur(20rpx);
			color: #fff;
			font-size: 22rpx;
			padding: 6rpx 14rpx;
			border-radius: 0 0 10rpx 0;
		}
	}

	.more {
		.mask {
			width: 100%;
			height: 100%;
			flex-direction: column;

			.text {
				font-size: 28rpx;
			}
		}
	}

	.content {}
</style>